<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head> 
	<title>Videshop POS</title> 
	<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
	<f:view>
		<table border="0" cellpadding="0" cellspacing="10">
			<tr>
				<td colspan="2"><h1>Videoshop POS</h1></td>
			</tr>
			<tr>
				<td valign="top">
					<table border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<!-- User section -->
								<f:subview id="userSection">
									<jsp:include page="user.jsp"/>
								</f:subview>
							</td>
						</tr>
						<tr>
							<td>
								<!-- Menu section -->
								<f:subview id="menuSection">
									<jsp:include page="menu.jsp"/>
								</f:subview>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" class="mainSection">
					<c:choose>
						<c:when test="${!empty userSection.staff && userSection.staff.manager}">
							<h2>Staff report</h2>

							<h:form>
								<h:panelGrid columns="2">
									<h:outputText styleClass="label" value="Store"/>
									<h:selectOneListbox	styleClass="select200" size="1" value="#{reportSection.selectedStoreId}">
										<f:selectItems value="#{reportSection.availableStores}"/>
									</h:selectOneListbox>
								</h:panelGrid>
								<h:panelGrid columns="4">
									<span class="label">From</span>
									<h:selectOneListbox styleClass="select50" size="1" value="#{reportSection.fromDateDay}">
										<f:selectItems value="#{dateComponent.days}"/>
									</h:selectOneListbox>
									<h:selectOneListbox styleClass="select100" size="1" value="#{reportSection.fromDateMonth}">
										<f:selectItems value="#{dateComponent.months}"/>
									</h:selectOneListbox>
									<h:selectOneListbox styleClass="select100" size="1" value="#{reportSection.fromDateYear}">
										<f:selectItems value="#{dateComponent.years}"/>
									</h:selectOneListbox>
									<span class="label">To</span>
									<h:selectOneListbox styleClass="select50" size="1" value="#{reportSection.toDateDay}">
										<f:selectItems value="#{dateComponent.days}"/>
									</h:selectOneListbox>
									<h:selectOneListbox styleClass="select100" size="1" value="#{reportSection.toDateMonth}">
										<f:selectItems value="#{dateComponent.months}"/>
									</h:selectOneListbox>
									<h:selectOneListbox styleClass="select100" size="1" value="#{reportSection.toDateYear}">
										<f:selectItems value="#{dateComponent.years}"/>
									</h:selectOneListbox>
								</h:panelGrid>
								
								<h:commandLink styleClass="button" action="#{reportSection.generateStaffReport}">
									<f:verbatim escape="true">Report</f:verbatim>
								</h:commandLink>
							</h:form>
							
							<c:if test="${!empty reportSection.staffReportStores}">
								<table class="dataTable" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<th width="200">Store</th>
										<th width="400">Staff</th>
										<th width="100" align="right">Movie processed</th>
									</tr>
								<c:forEach items="${reportSection.staffReportStores}" var="store">
									<tr>
										<td colspan="5">${store.store.storeName}</td>
									</tr>
									<c:forEach items="${store.staffs}" var="staffEntry">
										<tr>
											<td>&nbsp;</td>
											<td>${staffEntry.value.staff.firstName} ${staffEntry.value.staff.lastName}</td>
											<td align="right">${staffEntry.value.movieProcessed}</td>
										</tr>
									</c:forEach>
									<tr class="subSummary">
										<td colspan="2">Total</td>
										<td align="right">${store.movieProcessed}</td>
									</tr>
								</c:forEach>
								</table>
							</c:if>
							
						</c:when>
						<c:otherwise>
							Please login
						</c:otherwise>
					</c:choose>
					
				</td>
			</tr>
		</table>
	</f:view>
</html>